package communicationClasses;

import java.io.Serializable;

/**
 * An object the client sends to the server in order to request a transaction. A
 * transaction can either be of enum type WITHDRAW or DEPOSIT.
 */
public class TransactionRequest implements Serializable{

	private static final long serialVersionUID = -865503862966350307L;
	private String accountNumber;

	public String getAccountNumber() {
		return accountNumber;
	}

	public static enum TransactionType {
		WITHDRAW, DEPOSIT;
		public String toString() {
			switch (this) {
			case WITHDRAW:
				return "withdraw";
			case DEPOSIT:
				return "deposit";
			default:
				return null;
			}
		}
	};

	private TransactionType type;
	private int transactionAmount;

	/**
	 * creates a new TransactionRequest
	 * 
	 * @param amount
	 */
	public TransactionRequest(String accountNumber, TransactionType type,
			int amount) {
		this.accountNumber = accountNumber;
		this.type = type;
		transactionAmount = amount;
	}

	/**
	 * returns amount of the transaction
	 * 
	 * @return the amount
	 */
	public int getAmount() {
		return transactionAmount;
	}

	/**
	 * returns the transaction type
	 * 
	 * @return the transaction type
	 */
	public TransactionType getType() {
		return type;
	}

}
